/**
 * 动态加载官网页面上的主题菜单及其下拉类别选项
 */
/*$(document).ready(function(e) {

    // 设置主页链接
    var homePage = document.getElementById("homePage");
    homePage.setAttribute("href","/");

    // “关于协会”主题
    var about = document.getElementById("aboutS");
    about.setAttribute("href","/about");
    // 加载“关于协会”下的下拉菜单
    $.ajax({
        url:"/menu/aboutCategoryMapsJson",
        type:"get",
        dataType:"json",
        success:function(data){
            var aboutCategoryMaps = eval("("+data+")");
            var aCategory = document.getElementById("aCategory");
            for(var i=0;i< aboutCategoryMaps.length;i++){
                var li = document.createElement("li");
                var a = document.createElement("a");

                if (isPC()){
                    if(aboutCategoryMaps[i]["request_url"] != null && aboutCategoryMaps[i]["request_url"] != ''){
                        a.setAttribute("href",aboutCategoryMaps[i]["request_url"]);
                }
                }else {
                    if(aboutCategoryMaps[i]["wap_request_url"] != null && aboutCategoryMaps[i]["wap_request_url"] != ''){
                        a.setAttribute("href",aboutCategoryMaps[i]["wap_request_url"]);
                    }else{
                        a.setAttribute("href",aboutCategoryMaps[i]["request_url"]);
                    }
                }

                a.innerHTML = aboutCategoryMaps[i]["name"];
                li.appendChild(a);
                aCategory.appendChild(li);
            }
        }
    });

    // “新闻资讯”主题
    var webnews = document.getElementById("webnews");
    webnews.setAttribute("href","/webnews");
    // 加载“新闻资讯”主题的下拉菜单
    $.ajax({
        url:"/menu/newsCategoryMapsJson" ,
        type:"get",
        dataType:"json",
        success:function(data){
            var newsCategoryMaps = eval("("+data+")");
            var nCategory = document.getElementById("nCategory");
            for(var i=0;i< newsCategoryMaps.length;i++){
                var li = document.createElement("li");
                var a = document.createElement("a");

                if (isPC()){
                    if(newsCategoryMaps[i]["request_url"] != null && newsCategoryMaps[i]["request_url"] != ''){
                        a.setAttribute("href",newsCategoryMaps[i]["request_url"]);
                    }
                }else {
                    if(newsCategoryMaps[i]["wap_request_url"] != null && newsCategoryMaps[i]["wap_request_url"] != ''){
                        a.setAttribute("href",newsCategoryMaps[i]["wap_request_url"]);
                    }else{
                        a.setAttribute("href",newsCategoryMaps[i]["request_url"]);
                    }
                }

                if(newsCategoryMaps[i]["request_url"] != null && newsCategoryMaps[i]["request_url"] != ''){
                    a.setAttribute("href",newsCategoryMaps[i]["request_url"]);
                }
                a.innerHTML = newsCategoryMaps[i]["name"];
                li.appendChild(a);
                nCategory.appendChild(li);
            }
        }
    });


    // “新时代经理”主题
    var manager = document.getElementById("manager");
    manager.setAttribute("href","/npmes/ceo");
    // 加载“新时代经理”主题的下拉菜单
    $.ajax({
        url:"/menu/npmesCategoryMapsJson" ,
        type:"get",
        dataType:"json",
        success:function(data){
            var npmesCategoryMaps = eval("("+data+")");
            var mCategory = document.getElementById("mCategory");
            for(var i=0;i< npmesCategoryMaps.length;i++){
                var li = document.createElement("li");
                var a = document.createElement("a");

                if (isPC()){
                    if(npmesCategoryMaps[i]["request_url"] != null && npmesCategoryMaps[i]["request_url"] != ''){
                        a.setAttribute("href",npmesCategoryMaps[i]["request_url"]);
                    }
                }else {
                    if(npmesCategoryMaps[i]["wap_request_url"] != null && npmesCategoryMaps[i]["wap_request_url"] != ''){
                        a.setAttribute("href",npmesCategoryMaps[i]["wap_request_url"]);
                    }else{
                        a.setAttribute("href",npmesCategoryMaps[i]["request_url"]);
                    }
                }

                a.innerHTML = npmesCategoryMaps[i]["name"];
                li.appendChild(a);
                mCategory.appendChild(li);
            }
        }
    });

    // “专家团队”主题
    var professors = document.getElementById("professors");
    // professors.setAttribute("href","#");
    // 加载“专家团队”主题的下拉菜单
    $.ajax({
        url:"/menu/teamCategoryMapsJson" ,
        type:"get",
        dataType:"json",
        success:function(data){
            var teamCategoryMaps = eval("("+data+")");
            var pCategory = document.getElementById("pCategory");
            for(var i=0;i< teamCategoryMaps.length;i++){
                var li = document.createElement("li");
                var a = document.createElement("a");

                if (isPC()){
                    if(teamCategoryMaps[i]["request_url"] != null && teamCategoryMaps[i]["request_url"] != ''){
                        a.setAttribute("href",teamCategoryMaps[i]["request_url"]);
                    }
                }else {
                    if(teamCategoryMaps[i]["wap_request_url"] != null && teamCategoryMaps[i]["wap_request_url"] != ''){
                        a.setAttribute("href",teamCategoryMaps[i]["wap_request_url"]);
                    }else{
                        a.setAttribute("href",teamCategoryMaps[i]["request_url"]);
                    }
                }

                a.innerHTML = teamCategoryMaps[i]["name"];
                li.appendChild(a);
                pCategory.appendChild(li);
            }
        }
    });

    // “党建e家”主题
    var partyHome = document.getElementById("partyHome");
    partyHome.setAttribute("href","/party/culture");
    // 加载“党建e家”主题的下拉菜单
    $.ajax({
        url:"/menu/partyCategoryMapsJson" ,
        type:"get",
        dataType:"json",
        success:function(data){
            var partyCategoryMaps = eval("("+data+")");
            var phCategory = document.getElementById("phCategory");
            for(var i=0;i< partyCategoryMaps.length;i++){
                var li = document.createElement("li");
                var a = document.createElement("a");

                if (isPC()){
                    if(partyCategoryMaps[i]["request_url"] != null && partyCategoryMaps[i]["request_url"] != ''){
                        a.setAttribute("href",partyCategoryMaps[i]["request_url"]);
                    }
                }else {
                    if(partyCategoryMaps[i]["wap_request_url"] != null && partyCategoryMaps[i]["wap_request_url"] != ''){
                        a.setAttribute("href",partyCategoryMaps[i]["wap_request_url"]);
                    }else{
                        a.setAttribute("href",partyCategoryMaps[i]["request_url"]);
                    }
                }

                a.innerHTML = partyCategoryMaps[i]["name"];
                li.appendChild(a);
                phCategory.appendChild(li);
            }
        }
    });


    // “会员中心”主题
    var memberCenter = document.getElementById("memberCenter");
    memberCenter.setAttribute("href","/member/memberphoto");
    // 加载“会员中心”主题的下拉菜单
    $.ajax({
        url:"/menu/memberCategoryMapsJson" ,
        type:"get",
        dataType:"json",
        success:function(data){
            var memberCategoryMaps = eval("("+data+")");
            var mcCategory = document.getElementById("mcCategory");
            for(var i=0;i< memberCategoryMaps.length;i++){
                var li = document.createElement("li");
                var a = document.createElement("a");

                if (isPC()){
                    if(memberCategoryMaps[i]["request_url"] != null && memberCategoryMaps[i]["request_url"] != ''){
                        a.setAttribute("href",memberCategoryMaps[i]["request_url"]);
                    }
                }else {
                    if(memberCategoryMaps[i]["wap_request_url"] != null && memberCategoryMaps[i]["wap_request_url"] != ''){
                        a.setAttribute("href",memberCategoryMaps[i]["wap_request_url"]);
                    }else{
                        a.setAttribute("href",memberCategoryMaps[i]["request_url"]);
                    }
                }

                a.innerHTML = memberCategoryMaps[i]["name"];
                li.appendChild(a);
                mcCategory.appendChild(li);
            }
        }
    });
});*/

//如果返回的是false说明当前操作系统是手机端，如果返回的是true则说明当前的操作系统是电脑端
function isPC() {
    var userAgentInfo = navigator.userAgent;
    var Agents = ["Android", "iPhone",
        "SymbianOS", "Windows Phone",
        "iPad", "iPod"];
    var flag = true;
    for (var v = 0; v < Agents.length; v++) {
        if (userAgentInfo.indexOf(Agents[v]) > 0) {
            flag = false;
            break;
        }
    }
    return flag;
}
